var channelId;

window.onload = function () {
    channelId = getQuery("id");
    findByItem(1);
}

function findByItem(pageNo) {
    axios.get("/post/findByItem",{
        params: {
            pageNo:pageNo,
            channelId:channelId,
            postName:$("postName").value,
            userName: $("postWriter").value,
            startDate:$("startDate").value,
            endDate:$("endDate").value
        }
    }).then(resp=>{
        var info = resp.data;
        var str="";
        info.list.forEach(n=>{
            str+=`<tr><td>${n.postName}</td><td>${n.postWriter.userName}</td><td>${n.replyNum}</td><td>${n.date}</td>
            <td><input type="button" value="查看" onclick="location.href='/reply.html?id=${n.id}'"></td></tr>`;
        });
        $("data").innerHTML=str;
        var custr ="";
        for (var i=1;i<=info.totalPage;i++){
            custr+=`<a href="javascript:findByItem(${i})" style="margin-left: 10px">${i}</a>`;
        }
        $("cutDiv").innerHTML=custr;
    })
}

function add(){
    var str = "";
    str+=`/addPost.html?id=${channelId}`;
    location.href = str;
}



